<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组转换为分隔字符串</title>
</head>

<body>
    <script>
        var arr = ['刘备', '关羽', '张飞', '糕手'];
        var str = '';
        for (var i = 0; i < arr.length; i++) {

            // str += arr[i] + '|';
            str = arr.join('|');

        }
        console.log(str);
    </script>
</body>

</html>